﻿using System;
using System.Linq.Expressions;

namespace Kernelx.Extensions._Internals.Clauses.ClauseElement2Expressions
{

    internal class NestCreateExpressionMetadata : ICreateExpressionMetadata
    {
        private readonly Func<Expression, Expression> _createBody;
        private readonly ICreateExpressionMetadata _inner;
        public NestCreateExpressionMetadata(Func<Expression, Expression> createBody, ICreateExpressionMetadata inner)
        {
            _createBody = createBody;
            _inner = inner;
        }

        public Expression CreateBody(Expression member, Expression constant) => _createBody(_inner.CreateBody(member, constant));

        public Expression CreateConstant(object value, Type propType) => _inner.CreateConstant(value, propType);
    }
}
